<%@ include file="database_ini.jsp"%>


<%
	
	String status = "error";
	String Serailkey[] = request.getParameterValues("Serailkey");
	
	
	String type = request.getParameter("type");
	
	String CCParameterName = request.getParameter("CCParameterName");
	String StorerkeyFrom = request.getParameter("StorerkeyFrom");
	String StorerkeyTo = request.getParameter("StorerkeyTo");
	String SkuFrom = request.getParameter("SkuFrom");
	String SkuTo = request.getParameter("SkuTo");
	String ClassFrom = request.getParameter("ClassFrom");
	String ClassTo = request.getParameter("ClassTo");
	String ZoneFrom = request.getParameter("ZoneFrom");
	String ZoneTo = request.getParameter("ZoneTo");
	String LocFrom = request.getParameter("LocFrom");
	String LocTo = request.getParameter("LocTo");
	int XCOORDFROM = Integer.parseInt(request.getParameter("XCOORDFROM"));
	int XCOORDTO = Integer.parseInt(request.getParameter("XCOORDTO"));
	int YCOORDFROM = Integer.parseInt(request.getParameter("YCOORDFROM"));
	int YCOORDTO = Integer.parseInt(request.getParameter("YCOORDTO"));
	int ZCOORDFROM = Integer.parseInt(request.getParameter("ZCOORDFROM"));
	int ZCOORDTO = Integer.parseInt(request.getParameter("ZCOORDTO"));
	String DisplaySystemCount = request.getParameter("DisplaySystemCount");
	
	System.out.println("DisplaySystemCount: " + DisplaySystemCount);
	if(DisplaySystemCount==null){
		DisplaySystemCount = "0";
	}
	
	/**********/
	
	System.out.println("type: " + type);
	System.out.println("CCParameterName: " + CCParameterName);
	System.out.println("StorerkeyFrom: " + StorerkeyFrom);
	System.out.println("StorerkeyTo: " + StorerkeyTo);
	System.out.println("SkuFrom: " + SkuFrom);
	System.out.println("SkuTo: " + SkuTo);
	System.out.println("ClassFrom: " + ClassFrom);
	System.out.println("ClassTo: " + ClassTo);
	System.out.println("ZoneFrom: " + ZoneFrom);
	System.out.println("ZoneTo: " + ZoneTo);
	System.out.println("LocFrom: " + LocFrom);
	System.out.println("LocTo: " + LocTo);
	System.out.println("XCOORDFROM: " + XCOORDFROM);
	System.out.println("XCOORDTO: " + XCOORDTO);
	System.out.println("YCOORDFROM: " + YCOORDFROM);
	System.out.println("YCOORDTO: " + YCOORDTO);
	System.out.println("ZCOORDFROM: " + ZCOORDFROM);
	System.out.println("ZCOORDTO: " + ZCOORDTO);
	System.out.println("DisplaySystemCount: " + DisplaySystemCount);
	/**********/
	
	String stsql ="";
	Statement st;
	if (Serailkey == null) {
		
		stsql = " insert into CCParameter (CCParameterName, StorerkeyFrom, StorerkeyTo, SkuFrom, SkuTo, ClassFrom, ClassTo, ZoneFrom, ZoneTo, LocFrom, LocTo, XCOORDFROM, XCOORDTO, YCOORDFROM, YCOORDTO, ZCOORDFROM, ZCOORDTO, DisplaySystemCount) values( '" 
		+ CCParameterName + "', '" + StorerkeyFrom + "', '" + StorerkeyTo + "', '" 
		+ SkuFrom + "', '" + SkuTo + "', '" + ClassFrom + "', '" + ClassTo + "', '" + ZoneFrom + "', '" + ZoneTo + "', '" 
		+ LocFrom + "', '" + LocTo + "', '" + XCOORDFROM + "', '" + XCOORDTO + "', '" + YCOORDFROM + "', '" + YCOORDTO + "', '" 
		+ ZCOORDFROM + "', '" + ZCOORDTO + "', '" + DisplaySystemCount + "')";
		/*********debug*/
		System.out.println("stsql: " + stsql);
		/**********/
		
		st = conn.createStatement();
		st.executeUpdate(stsql);
	}
	else{
		/*********debug*/
		System.out.println("Serailkey: " + Serailkey[0]);
		/**********/
		
		stsql = " update CCParameter set CCParameterName = '" +CCParameterName+ "', StorerkeyFrom = '" +StorerkeyFrom+ "', StorerkeyTo = '" +StorerkeyTo+ "', SkuFrom = '" +SkuFrom+ "', SkuTo = '" +SkuTo+ "', ClassFrom = '" +ClassFrom+ "', ClassTo = '" +ClassTo+ "', ZoneFrom = '" +ZoneFrom+ "', ZoneTo = '" +ZoneTo+ "', LocFrom = '" +LocFrom+ "', LocTo = '" +LocTo+ "', XCOORDFROM = '" +XCOORDFROM+ "', XCOORDTO = '" +XCOORDTO+ "', YCOORDFROM = '" +YCOORDFROM+ "', YCOORDTO = '" +YCOORDTO+ "', ZCOORDFROM = '" +ZCOORDFROM+ "', ZCOORDTO = '" +ZCOORDTO+ "', DisplaySystemCount = '" +DisplaySystemCount+ "' "
		+ "where Serailkey = " + Integer.parseInt(Serailkey[0]) ;
		/*********debug*/
		System.out.println("stsql: " + stsql);
		/**********/

		st = conn.createStatement();
		st.executeUpdate(stsql);
		
		
	}
	conn.close();
	
	
	status = "ok";
	String action = "save";
	String rep = CCParameterName;
	
	//已成功更新保存
	//status = CCParameterName + "已成功更新保存";
	
	response.sendRedirect("index.jsp?status=" + status + "&action=" + action);
	//response.sendRedirect("index.jsp?status=" + java.net.URLEncoder.encode(status));
	//response.sendRedirect("index.jsp?status=" + java.net.URLEncoder.encode(status, "UTF-8"));
%>